class A {
  readonly name: string;
  public age: number;
  protected sex: string;
  private tel: string;
  constructor(name: string, age: number, sex: string, tel: string) {
    this.name = name;
    this.age = age;
    this.sex = sex;
    this.tel = tel;
  }
  test() {
    console.log(this.name);
    console.log(this.age);
    console.log(this.sex);
    console.log(this.tel);
  }
}

class B extends A {
  constructor(name: string, age: number, sex: string, tel: string) {
    super(name, age, sex, tel);
  }
  test() {
    console.log(this.name);
    console.log(this.age);
    console.log(this.sex);
    // protected修饰的属性不能在子类中访问
    // console.log(this.tel); // 警告 tel私有只能在A中访问
  }
}

const b = new B("李四", 19, "男", "123456789");
console.log(b.name);
console.log(b.age);
// protected和private修饰的属性不能在对象中访问
// console.log(b.sex); // 警告 sex受保护只能在A和A的子类中访问
// console.log(b.tel);// 警告 tel私有只能在A中访问
